package Level03_four_important;

import java.util.ArrayList;
import java.util.Collections;

public class Test {
    public static void main(String[] args) {
        String[] suit = {"♠", "♥", "♦", "♣"};
        String[] rank = {"A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K"};
        ArrayList<String> poker = new ArrayList<>();
        for (String s : suit) {
            for (String r : rank) {
                poker.add(s + r);
            }
        }
        Collections.shuffle(poker);//将集合打散
        //定义四个玩家
        ArrayList<String> player = new ArrayList<>();
        ArrayList<String> player1 = new ArrayList<>();
        ArrayList<String> player2 = new ArrayList<>();
        ArrayList<String> player3 = new ArrayList<>();
        for (int i = 0; i < 8; i++) {
            switch (i % 4) {
                case 0:
                    player.add(poker.get(i));
                    break;
                case 1:
                    player1.add(poker.get(i));
                    break;
                case 2:
                    player2.add(poker.get(i));
                    break;
                case 3:
                    player3.add(poker.get(i));
            }
        }
        System.out.println("玩家1：" + player);
        System.out.println("玩家2：" + player1);
        System.out.println("玩家3：" + player2);
        System.out.println("玩家4：" + player3);
        //比较四位玩家，两张扑克牌的大小，不考虑花色
        Size size = new Size();
        int size1 = size.size(player);
        int size2 = size.size(player1);
        int size3 = size.size(player2);
        int size4 = size.size(player3);
        System.out.println("玩家一的值为："+size1);
        System.out.println("玩家二的值为："+size2);
        System.out.println("玩家三的值为："+size3);
        System.out.println("玩家四的值为："+size4);
        //判断最大值
        ArrayList<Object> SIZE = new ArrayList<>();
        SIZE.add(size1);
        SIZE.add(size2);
        SIZE.add(size3);
        SIZE.add(size4);
        int max = Integer.MIN_VALUE;
        int MAX = 0;
        for (Object o : SIZE) {
            String s = o.toString();
            int i = Integer.parseInt(s);
            MAX = i > max ? max = (int) o : max;
        }
        System.out.println("最大值：" + MAX);

    }
}

